<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>合众人寿公益平台客户管理系统</title>
		<style>
body,ul,ol,dl,dd,p,h1,h2,h3,h4,h5,h6,form,input,textarea,select,td,th {
	margin: 0;
	padding: 0;
	font-family: "宋体", Arial, Helvetica, sans-serif;
}

li {
	list-style: none;
}

input {
	background: none;
}

.clear {
	zoom: 1;
}

.clear:after {
	content: "";
	display: block;
	clear: both;
}
</style>
        <SCRIPT type="text/javascript">
	      var GB_ROOT_DIR = "<%=request.getContextPath()%>/html/skin/";
        </SCRIPT>
		<link href="<%=request.getContextPath()%>/html/css/Main.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=request.getContextPath()%>/html/js/AJS.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/html/js/AJS_fx.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/html/js/gb_scripts.js"></script>
		<link href="<%=request.getContextPath()%>/html/css/gb_styles.css" rel="stylesheet" type="text/css" />

		<SCRIPT type="text/javascript">
     function check(){
     	if(leftTrim(document.getElementById("receive").value)== ''){
     	   alert("请输入收件人!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("theme").value) == ''){
     	   alert("请输入主题!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("content").value) == ''){
     	   alert("请输入发送内容!");
     	   return false;
     	}
     }
     
     
	
	function $(id){
		return document.getElementById(id);//全局变量，记录文件数；
	}
	var fileNum=1;
	//mouseover时，把input file移到按扭上，保证点击的是file，
	function floatFile()
	{ 
	$("file"+fileNum).style.posTop=event.srcElement.offsetTop;
	$("file"+fileNum).style.posLeft=event.x-$("file"+fileNum).offsetWidth/2; }
	//选择完一个文件之后，自动创建一个新的div 和 file表单，用于下回使用，hidden刚用过的file
	function showText(obj)
	{
	var name = obj.value.substring(obj.value.lastIndexOf("\\")+1);
	$(obj.id+"text").innerHTML=name+"&nbsp;&nbsp;<a href='javascript:del("+fileNum+")'>删除</a>";
	$("file"+fileNum).style.display='none';
	$("fileName"+fileNum).value=$("file"+fileNum).value;
	fileNum=fileNum+1;
	//直接追加innerHTML(innerHTML+=)会清空原来file中的内容 
	$("div"+(fileNum-1)).insertAdjacentHTML('AfterEnd','<div id="div'+fileNum+'"><div id="file'+fileNum+'text" ></div><input id="file'+fileNum+'" name="attachFiles" type="file" onchange="showText(this)" style="position:absolute;filter:alpha(opacity=0);width:30px;"><input type="hidden" name="fileName" id="fileName'+fileNum+'" /></div>');
	}
	function del(id)
	{
	$("div"+id).innerHTML="";
	$("div"+id).style.display="none";
	}
	
	function selunit(){
		GB_showCenter("从会员列表选取收件人","<%=request.getContextPath()%>/mail/toGetReceives.do",500,900);
	}
	function selunit2(){
		GB_showCenter("从会员列表选取抄送人","<%=request.getContextPath()%>/mail/toGetCopies.do",500,900);
	}
	
	
	function   leftTrim(ui){  
	    var   notValid=/^\s/;  
	    while(notValid.test(ui)){  
	      ui=ui.replace(notValid,"");}  
       return   ui; 
       }  
	 </SCRIPT>

	</head>

	<body>
		<div class="container">
			<div class="wrap clear">
				<div class="sub_wp_right">
					<div class="rt_tt">
						<h3 class="tittle">
							发送邮件
						</h3>
					</div>
					<div class="ct">
						<form action="<%=request.getContextPath()%>/mail/sendMail.do"
							method="post" onsubmit="return check()"
							enctype="multipart/form-data" name="impForm">
							<div class="add">
								<table>
									<tr>
										<td class="right">
											<span>发件人：</span>
										</td>
										<td class="t2">
											<input type="text" name="mailRecord.sender.user_Name"
												id="memberName"
												value="${sender}"
												style="border: 0; text-decoration: underline;" />
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>收件人<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<input type="text" name="receive" id="receive"
												style="width: 450px;" readonly="readonly"/>
											<input type="hidden" name="receiveId" id="receiveId"/>
										</td>
										<td>
											<input type="button" value="添加收件人" onclick="selunit()"
												style="cursor: pointer; float: left;" />
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>抄送人：</span>
										</td>
										<td style="width: 160px;" class="t2">
											<input type="text" name="copyTo" id="copyTo"
												style="width: 450px;" readonly="readonly"/>
										  <input type="hidden" name="copyToId" id="copyToId"/>
										</td>
										<td>
										  <input type="button" value="添加抄送人" onclick="selunit2()"
												style="cursor: pointer; float: left;" />
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>主题<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<input type="text" name="mailRecord.theme" id="theme"
												style="width: 450px;" />
										</td>
									</tr>

									<tr>
										<td>
										</td>
										<td align="left">
											<div id="tt" style="position: relative;">
												<input type="button" value="添加照片" onmouseover="floatFile()">
												<br>
												<div id="div1">
													<div id="file1text"></div>
													<input id="file1" name="attachFiles" type="file"
														onchange="showText(this)"
														style="position: absolute; filter: alpha(opacity =     0); width: 30px; height: 20px">
													<input type="hidden" name="fileName" id="fileName1" />
												</div>
											</div>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>内容<font color="red">(*)</font>：</span>
										</td>
										<td colspan="2" class="t2">
											<textarea rows="10" cols="78" name="mailRecord.content"
												id="content"></textarea>
										</td>
									</tr>
								</table>
							</div>
							<div class="btn">
								<input type="submit" value="发送" />
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
